package com.ngo.model.vo;

import com.ngo.constant.Response;

import java.io.Serializable;


/**
 * @author yang.yang@karakal.com.cn
 * @version V1.0
 * @Description:
 * @date 2017-09-30 14:45
 */
public class ResponseVO<T> implements Serializable {

	private static final long serialVersionUID = 1L;
	// 自定义数据
	private String state;
	private String message;
	private T data;

	public String getState() {
		return state;
	}

	public void setState(String state) {
		this.state = state;
	}

	public String getMessage() {
		return message;
	}

	public void setMessage(String message) {
		this.message = message;
	}

	public T getData() {
		return data;
	}

	public void setData(T data) {
		this.data = data;
	}

	public static <T> ResponseVO<T> success(T data) {
		ResponseVO<T> responseVO = new ResponseVO<T>();
		responseVO.setState(Response.SUCCESS.getState());
		responseVO.setMessage(Response.SUCCESS.getMessage());
		responseVO.setData(data);
		return responseVO;
	}

	public static <T> ResponseVO<T> success() {
		ResponseVO<T> responseVO = new ResponseVO<T>();
		responseVO.setState(Response.SUCCESS.getState());
		responseVO.setMessage(Response.SUCCESS.getMessage());
		return responseVO;
	}

	public static <T> ResponseVO<T> error(Response response) {
		ResponseVO<T> responseVO = new ResponseVO<T>();
		responseVO.setState(response.getState());
		responseVO.setMessage(response.getMessage());
		return responseVO;
	}

	public static <T> ResponseVO<T> error(String state, String message) {
		ResponseVO<T> responseVO = new ResponseVO<T>();
		responseVO.setState(state);
		responseVO.setMessage(message);
		return responseVO;
	}
}
